#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

COPY ["Directory.Packages.props", "."]
COPY ["Directory.Build.props", "."]
COPY ["global.json", "."]
COPY ["nuget.config", "."]
COPY [".editorconfig", "."]
COPY ["*.sln", "."]
COPY ["src/**/*.csproj", "./"]
#COPY ["test/**/*.csproj", "./"]
RUN dotnet sln list | grep ".csproj" \
    | while read -r line; do \ 
    mkdir -p $(dirname $line); \
    mv $(basename $line) $(dirname $line); \
    done;
RUN dotnet restore

COPY . .
WORKDIR "/src/src/JackProjectTemplate.Web"
RUN dotnet build "./JackProjectTemplate.Web.csproj" -c $BUILD_CONFIGURATION --no-restore -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./JackProjectTemplate.Web.csproj" -c $BUILD_CONFIGURATION --no-restore -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV TZ="Asia/Shanghai"
ENV ASPNETCORE_HTTP_PORTS=80
#ENTRYPOINT ["dotnet", "JackProjectTemplate.Web.dll", "--urls", "http://*:80"]
ENTRYPOINT ["dotnet", "JackProjectTemplate.Web.dll"]
